
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 09/04/2018 17:40:43
-- Generated from EDMX file: D:\CommunityProject\1.0\Feicui.BeautyCRM\Feicui.BeautyCRM.Model\Beauty.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [Beauty];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Beauty_User]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Beauty_User];
GO
IF OBJECT_ID(N'[dbo].[Beauty_Role]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Beauty_Role];
GO
IF OBJECT_ID(N'[dbo].[Beauty_Menu]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Beauty_Menu];
GO
IF OBJECT_ID(N'[dbo].[Beauty_Transaction]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Beauty_Transaction];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Beauty_User'
CREATE TABLE [dbo].[Beauty_User] (
    [UserId] varchar(36)  NOT NULL,
    [Code] varchar(50)  NOT NULL,
    [UserName] nvarchar(50)  NOT NULL,
    [Password] varchar(50)  NOT NULL,
    [UserSex] int  NOT NULL,
    [UserPhone] varchar(20)  NOT NULL,
    [UserRealName] nvarchar(20)  NOT NULL,
    [RoleIds] varchar(2000)  NOT NULL,
    [Enabled] int  NOT NULL,
    [CreateDate] datetime  NOT NULL,
    [Ext1] varchar(500)  NOT NULL,
    [Ext2] varchar(500)  NOT NULL,
    [Ext3] varchar(500)  NOT NULL
);
GO

-- Creating table 'Beauty_Role'
CREATE TABLE [dbo].[Beauty_Role] (
    [RoleId] varchar(36)  NOT NULL,
    [Code] varchar(50)  NOT NULL,
    [RoleName] nvarchar(50)  NOT NULL,
    [Description] nvarchar(200)  NOT NULL,
    [menuIds] varchar(5000)  NOT NULL,
    [Enabled] int  NOT NULL,
    [CreateDate] datetime  NOT NULL,
    [Ext1] varchar(500)  NOT NULL,
    [Ext2] varchar(500)  NOT NULL,
    [Ext3] varchar(500)  NOT NULL
);
GO

-- Creating table 'Beauty_Menu'
CREATE TABLE [dbo].[Beauty_Menu] (
    [MenuId] varchar(36)  NOT NULL,
    [ParentId] varchar(50)  NOT NULL,
    [Code] varchar(50)  NOT NULL,
    [MenuName] nvarchar(50)  NOT NULL,
    [Description] nvarchar(200)  NOT NULL,
    [NavigateUrl] varchar(200)  NOT NULL,
    [Enabled] int  NOT NULL,
    [SortCode] int  NOT NULL,
    [CreateDate] datetime  NOT NULL,
    [Ext1] varchar(500)  NOT NULL,
    [Ext2] varchar(500)  NOT NULL,
    [Ext3] varchar(500)  NOT NULL
);
GO

-- Creating table 'Beauty_Transaction'
CREATE TABLE [dbo].[Beauty_Transaction] (
    [TransactionId] varchar(36)  NOT NULL,
    [Code] varchar(50)  NOT NULL,
    [TransactionName] nvarchar(50)  NOT NULL,
    [TransactionType] int  NOT NULL,
    [Description] nvarchar(200)  NOT NULL,
    [Enabled] int  NOT NULL,
    [CreateDate] datetime  NOT NULL,
    [Ext1] varchar(500)  NOT NULL,
    [Ext2] varchar(500)  NOT NULL,
    [Ext3] varchar(500)  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [UserId] in table 'Beauty_User'
ALTER TABLE [dbo].[Beauty_User]
ADD CONSTRAINT [PK_Beauty_User]
    PRIMARY KEY CLUSTERED ([UserId] ASC);
GO

-- Creating primary key on [RoleId] in table 'Beauty_Role'
ALTER TABLE [dbo].[Beauty_Role]
ADD CONSTRAINT [PK_Beauty_Role]
    PRIMARY KEY CLUSTERED ([RoleId] ASC);
GO

-- Creating primary key on [MenuId] in table 'Beauty_Menu'
ALTER TABLE [dbo].[Beauty_Menu]
ADD CONSTRAINT [PK_Beauty_Menu]
    PRIMARY KEY CLUSTERED ([MenuId] ASC);
GO

-- Creating primary key on [TransactionId] in table 'Beauty_Transaction'
ALTER TABLE [dbo].[Beauty_Transaction]
ADD CONSTRAINT [PK_Beauty_Transaction]
    PRIMARY KEY CLUSTERED ([TransactionId] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------